using System.Web.Mvc;
using Coleotrack.Common.Registration;
using Coleotrack.Service.Registration;
using Coleotrack.Web;
using Coleotrack.Web.Registration;
using StructureMap;

namespace Coleotrack
{
    public static class Bootstrapper
    {
        public static void BootstrapWithDatabase(string connectionString, bool createSchema)
        {
            ObjectFactory.Initialize(x =>
            {
                x.AddRegistry(new NHibernateRegistry(connectionString, createSchema));
                x.AddRegistry<CommonRegistry>();
                x.AddRegistry<ServiceRegistry>();
                x.AddRegistry<WebRegistry>();
            });

            ControllerBuilder.Current.SetControllerFactory(new StructureMapControllerFactory());
        }

        public static void BootstrapWithoutDatabase()
        {
            ObjectFactory.Initialize(x =>
            {
                x.AddRegistry<CommonRegistry>();
                x.AddRegistry<ServiceRegistry>();
                x.AddRegistry<WebRegistry>();
            });

            ControllerBuilder.Current.SetControllerFactory(new StructureMapControllerFactory());
        }
    }
}